package com.dalongxin.work.page.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.andview.refreshview.recyclerview.BaseRecyclerAdapter;
import com.dalongxin.work.R;
import com.dalongxin.work.data.Pay;

import java.util.List;
/**
 * 付款申请Adapter
 */
public class PayAdapter extends BaseRecyclerAdapter<PayAdapter.PayViewHolder> {

    private List<Pay> mData;

    public PayAdapter(List<Pay> mData) {
        this.mData = mData;
    }

    @Override
    public PayViewHolder getViewHolder(View view) {
        return new PayViewHolder(view, true);
    }

    @Override
    public PayViewHolder onCreateViewHolder(ViewGroup parent, int viewType, boolean isItem) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_dj_list, parent, false);
        return new PayViewHolder(v, true);
    }

    @Override
    public void onBindViewHolder(PayViewHolder holder, int position, boolean isItem) {
        if(mData != null) {
            Pay item = mData.get(position);
            if (item != null) {
                holder.titleText1.setText(item.getReceiveCompany());
                holder.descText1.setText("总金额：￥" + item.getTotalFee() + "元");
                holder.titleText2.setText(item.getCreateName());
                holder.descText2.setText(item.getFillDate());
            }
        }
    }

    @Override
    public int getAdapterItemCount() {
        return mData == null ? 0 : mData.size();
    }

    public class PayViewHolder extends RecyclerView.ViewHolder {

        private TextView titleText1;
        private TextView descText1;
        private TextView titleText2;
        private TextView descText2;
        public PayViewHolder(View itemView, boolean isItem) {
            super(itemView);
            titleText1 = itemView.findViewById(R.id.text_title1);
            descText1 = itemView.findViewById(R.id.text_desc1);
            titleText2 = itemView.findViewById(R.id.text_title2);
            descText2 = itemView.findViewById(R.id.text_desc2);
        }
    }
}
